/* 全局样式 */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #BBDEFB;
    --background-color: #FFFFFF;
    --surface-color: #F5F5F5;
    --border-color: #E0E0E0;
    --text-primary: #212121;
    --text-secondary: #757575;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    background-color: var(--background-color);
}

.app-container {
    display: flex;
    height: 100vh;
    background-color: var(--background-color);
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* 内容区样式 */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 工具栏样式 */
.toolbar {
    padding: 16px;
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.toolbar-left {
    flex: 1;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

.note-title {
    width: 100%;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    transition: all 0.2s ease;
}

.note-title:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* 按钮样式 */
.button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--background-color);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.button:hover {
    background-color: var(--surface-color);
    border-color: var(--text-secondary);
}

.button.primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.button.primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.button .mdi {
    font-size: 18px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button:hover {
    background-color: var(--surface-color);
    color: var(--primary-color);
}

.icon-button .mdi {
    font-size: 20px;
}

/* 编辑器容器样式 */
.editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: var(--background-color);
    position: relative;
}

#editor {
    flex: 1;
    min-width: 0;
    transition: width 0.3s ease;
}

.markdown-preview {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    background-color: var(--surface-color);
    min-width: 0;
    transition: width 0.3s ease;
}

/* 预览隐藏状态 */
.editor-container.preview-hidden .markdown-preview {
    display: none;
}

.editor-container.preview-hidden #editor {
    flex: 1;
}

/* 预览按钮激活状态 */
#previewToggleBtn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

#previewToggleBtn.active:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* 文件树项目样式 */
.tree-item {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    margin: 2px 0;
    position: relative;
}

.tree-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.tree-item.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.tree-item .icon {
    font-size: 18px;
    color: var(--text-secondary);
    width: 20px;
    text-align: center;
}

.tree-item.active .icon {
    color: var(--primary-color);
}

.tree-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 文件夹样式 */
.folder {
    position: relative;
}

.folder .folder-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.folder .folder-header:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.folder .folder-content {
    display: none;
    padding-left: 20px;
    position: relative;
}

.folder .folder-content::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--border-color);
}

.folder.expanded > .folder-content {
    display: block;
}

.folder .folder-content .tree-item {
    position: relative;
}

.folder .folder-content .tree-item::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    width: 10px;
    height: 1px;
    background-color: var(--border-color);
}

.folder .folder-content .folder::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 19px;
    width: 10px;
    height: 1px;
    background-color: var(--border-color);
}

/* Markdown 预览样式 */
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

.markdown-preview h1 { font-size: 2em; }
.markdown-preview h2 { font-size: 1.5em; }
.markdown-preview h3 { font-size: 1.25em; }
.markdown-preview h4 { font-size: 1em; }
.markdown-preview h5 { font-size: 0.875em; }
.markdown-preview h6 { font-size: 0.85em; }

.markdown-preview p {
    margin-bottom: 16px;
    line-height: 1.6;
}

.markdown-preview code {
    padding: 0.2em 0.4em;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 85%;
}

.markdown-preview pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-preview pre code {
    padding: 0;
    background-color: transparent;
}

.markdown-preview blockquote {
    padding: 0 1em;
    color: var(--text-secondary);
    border-left: 0.25em solid var(--border-color);
    margin-bottom: 16px;
}

.markdown-preview ul,
.markdown-preview ol {
    padding-left: 2em;
    margin-bottom: 16px;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.markdown-preview table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
}

.markdown-preview table th,
.markdown-preview table td {
    padding: 6px 13px;
    border: 1px solid var(--border-color);
}

.markdown-preview table tr:nth-child(2n) {
    background-color: var(--surface-color);
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #C1C1C1;
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #A8A8A8;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 240px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .button span:not(.mdi) {
        display: none;
    }

    .button {
        padding: 8px;
    }
}
